#include <iostream>
using namespace std;

int main()
{
	int n;
	cin >>n;
	int x;
	cin >> x;
	int arr[100];
	for(int i = 0; i < n+1; i++)
	{
		cin >> arr[i];
	}
	
	int sum = 0;
	for(int i = n; i >= 0; i--)
	{
		sum  = x*sum + arr[i];
	}
	cout << sum << endl;
	return 0;
}
